#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
rm $0
IP=$(curl -s -4 ipinfo.io/ip)
echo "即将安装版本为： MySQL 版本：5.5.54  PHP版本： 5.6.30   Apache版本：Apache 2.0"
sleep 1
echo "请稍等，正在准备LAMP环境..."
sleep 1
echo "请输入mysql数据库密码："
read mp
echo "您输入的密码为："$mp
echo "确认安装请输入y继续，否则输入Ctrl+C取消安装！"
read yes
#安装Apache
yum -y install httpd
chkconfig httpd on
service httpd start
#安装mysql
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm; #更改yum源
yum -y install mysql mysql-server mysql-devel; #安装mysql
sleep 1
chkconfig mysqld on #检查mysql服务
service mysqld start #启动mysql
#修改mysql密码
mysqladmin -u root password $mp
sleep 2
#安装PHP5.6
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum list --enablerepo=remi --enablerepo=remi-php56 | grep php;
yum -y install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-mysql php-gd
yum -y install --enablerepo=remi --enablerepo=remi-php56 php-fpm  
#安装adminer.php简易数据库
cd /var/www/html/
wget --no-check-certificate https://git.oschina.net/4ker/lamp-centos6.x/raw/master/tz.php>/dev/null 2>&1
service httpd restart #重启Apache
service mysqld restart #重启MySQL数据库
wget --no-check-certificate https://git.oschina.net/4ker/lamp-centos6.x/raw/master/mysql.php>/dev/null 2>&1

echo "安装完成！"
echo "——————————————————————————"
echo "请输入$IP/tz.php查看php探针。"
echo "请输入$IP/mysql.php管理数据库。"
echo "——————————————————————————"
echo;echo;
echo "刺客博客，地址：http://4ker.cc"